package com.boang.controller.login;

import cn.dev33.satoken.stp.SaTokenInfo;
import cn.dev33.satoken.stp.StpUtil;
import com.boang.entity.LoginReq;
import com.boang.entity.LoginRes;
import com.boang.resp.Result;
import com.boang.service.SysUserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 13813
 */
@Tag(name = "用户登录", description = "用户登录相关")
@RestController
public class LoginController {

//    @Resource
//    SysUserService adminService;
//
//    @Operation(summary = "用户登录")
//    @PostMapping("/login")
//    public Result<LoginRes> doLogin(@Validated @RequestBody LoginReq login) {
//        return Result.ok(adminService.login(login));
//    }

    @GetMapping("/isLogin")
    public Result<String> isLogin() {
        return Result.ok("是否登录：" + StpUtil.isLogin());
    }

    @GetMapping("/tokenInfo")
    public Result<SaTokenInfo> tokenInfo() {
        return Result.ok(StpUtil.getTokenInfo());
    }

    @GetMapping("/logout")
    public Result<String> logout() {
        StpUtil.logout();
        return Result.ok("注销成功");
    }
}




